package ru.lukyanets.transmission.protocol.model.torrent;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author Sergey Lukyanets
 */
public enum TorrentStatus {
    STOPPED, /* Torrent is stopped */
    CHECK_WAIT, /* Queued to check files */
    CHECK, /* Checking files */
    DOWNLOAD_WAIT, /* Queued to download */
    DOWNLOAD, /* Downloading */
    SEED_WAIT, /* Queued to seed */
    SEED; /* Seeding */

    @JsonValue
    public int toValue() {
        return ordinal();
    }

    @JsonCreator
    public static TorrentStatus forValue(int value) {
        return value >= 0 && value < TorrentStatus.values().length ? TorrentStatus.values()[value] : null;
    }
}
